class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-08-26",
      revision: "0388680649021cadeb0c0faf59f01cc2f658ec94"
  version "2021-08-26"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "a0b1c73eb16f503bf39f61c88db585cd6821f257724fd67a77c3e2934b362048"
    sha256 cellar: :any_skip_relocation, big_sur:       "9e7afb7b13928d57c12e994f24372b99030c345ac0d935b4d18781f891c3d2de"
    sha256 cellar: :any_skip_relocation, catalina:      "badd69e2ecc7cbfb186210066419f7eb2564f79015f87727d9ca1e376d43b4de"
    sha256 cellar: :any_skip_relocation, mojave:        "7f8dc0add071b8979cd986c3ad8128c778c8c8e560cce8d32217eed59d3e66da"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "63cff319ec077b7f3569898b0bdbadea0052f287409a3da5492cda67abcb5540"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
